//
//  SNOrganizationModel.m
//  testmodel_test
//
//  Created by stone on 17/1/8.
//  Copyright © 2017年 stone. All rights reserved.
//

#import "SNOrganizationModel.h"

@implementation SNOrganizationModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{ @"VOID" : @"void"};
}
+ (NSDictionary *)objectClassInArray{
    return @{@"result" : [SNOrganizationResult class]};
}
@end
@implementation SNOrganizationResult

+ (NSDictionary *)objectClassInArray{
    return @{@"custinfoList" : [SNOrganizationCustinfolist class]};
}

-(void)setAddress:(NSString *)address{
    _address = address;
    
    NSLog(@"address = %@",address);
    
    NSArray<NSString *> * strings =  [address componentsSeparatedByString:@"|"];
    
    NSMutableString * strM = [NSMutableString string];
    for(int i = 0; i < strings.count; i++) {
        if (i == strings.count - 1) {
            //            NSLog(@"%@",[self foo:strings[i] needNumber:YES]);
            [strM appendString:[self foo:strings[i] needNumber:YES]];
        }else{
            
            //            NSLog(@"%@",[self foo:strings[i] needNumber:NO]);
            [strM appendString:[self foo:strings[i] needNumber:NO]];
        }
    }
    
    self.filteredAddress = strM;
}
- (NSString *)foo:(NSString *)str needNumber:(BOOL)needNumber
{
    NSMutableString * strM = [NSMutableString string];
    NSString *searchText = str;
    
    NSString * RegExString;
    if (needNumber) {
        
        RegExString = @"[\u4E00-\u9FFF\\d]+";
    }else{
        RegExString = @"[\u4E00-\u9FFF]+";
        
    }
    
    NSRange range = [searchText rangeOfString:RegExString options:NSRegularExpressionSearch];
    while (range.location != NSNotFound) {
        
        [strM appendString:[NSString stringWithFormat:@"%@ ",[searchText substringWithRange:range]]];
        searchText =  [searchText substringFromIndex:range.location+range.length];
        range = [searchText rangeOfString:RegExString options:NSRegularExpressionSearch];
    }
    //    NSLog(@"%@",strM);
    
    return strM;
    
    
    /*
     NSRange range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
     while (range.location != NSNotFound) {
     
     [strM appendString:[NSString stringWithFormat:@"%@ ",[searchText substringWithRange:range]]];
     searchText =  [searchText substringFromIndex:range.location+range.length];
     range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
     }
     
     //    NSLog(@"strM = %@",strM);
     
     return strM;
     */
}
@end


@implementation SNOrganizationCustinfolist

@end


